/**
 *
 * @author chenzefang
 *
 * 面包屑组件
 * @class Breadcrumb
 * @extends Basic
 * @param [separator ">" 默认分隔符
 *
 * 示例：
 *
 *     @example
 *     var Breadcrumb = UcsmyUI.Breadcrumb;
 *     var Item = Breadcrumb.Item;
 *     <Breadcrumb separator='/' >
 *     <Item>首页</Item>
 *     <Item href="baidu.com">我的账户</Item>
 *     <Item href="baidu.com">个人信息</Item>
 *     </Breadcrumb>
 *
 */
var Breadcrumb = React.createClass({
    getDefaultProps: function(){
        return{
            separator:'>'   //分隔符
        }
    },
    render: function(){
        var that = this;
        var len = this.props.children.length;
        return (
            <div className='ucs-breadcrumb'>
                {
                    this.props.children.map(function (child,index) {
                        if(index == len-1){
                            return <span className='ucs-breadcrumb-link-last'>{child}</span>;
                        }else{
                            return <span>{child}<span className="ucs-breadcrumb-separator">{that.props.separator}</span></span>;
                        }
                    })
                }
            </div>
        )
    }
});
Breadcrumb.Item = React.createClass({
    render: function () {
        return (
            this.props.href ?
                <a href={this.props.href}>{this.props.children}</a> :
                <span>{this.props.children}</span>
        )
    }
});

module.exports = Breadcrumb;